<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class BusinessScope extends Model
{
    //
    protected $table = 'business_scope';
    protected $appends = ['parent_name'];

    public function upper()
    {
        return $this->belongsTo(self::class, 'parent');
    }

    public function getParentNameAttribute()
    {
        if ($this->attributes['parent'] != 0) {
            return $this->upper->name;
        }
        return $this->attributes['name'];
    }





}
